package com.beiye.drivertransport.SubActivity;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.beiye.drivertransport.R;
import com.beiye.drivertransport.activity.TwoBaseAty;
import com.beiye.drivertransport.utils.FileUtil;
import com.beiye.drivertransport.utils.QRCodeUtil;
import com.githang.statusbar.StatusBarCompat;


import butterknife.OnClick;

import static com.beiye.drivertransport.config.AppInterfaceConfig.BASE_URL;

/**
 * Copyright (C)
 * Author: 刘学章
 * Date: 2021-4-13 10:27:19
 * Description:
 */
public class PromotionCodeActivity extends TwoBaseAty {


    ImageView imgBack;

    ImageView acPcodeIv;

    TextView acPcodeTv;
    private int uoSn;
    private Bitmap bitmap;

    @Override
    public int getLayoutId() {
        return R.layout.activity_promotion_code;
    }

    @Override
    public void initData() {
        imgBack = (ImageView) findViewById(R.id.img_back);
        acPcodeIv = (ImageView) findViewById(R.id.ac_pcode_iv);
        acPcodeTv = (TextView) findViewById(R.id.ac_pcode_tv);
        StatusBarCompat.setStatusBarColor(this, Color.parseColor("#1F80C4"));
        Bundle bundle = getIntent().getExtras();
        uoSn = bundle.getInt("uoSn");

        String regUrl = BASE_URL + "wx/toReg?uoSn=" + uoSn;
        bitmap = QRCodeUtil.createQRCode(regUrl, (int) getResources().getDimension(R.dimen.x400));
        acPcodeIv.setImageBitmap(bitmap);
    }

    @Override
    public void requestData() {

    }



    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.img_back) {
            finish();
        } else if (id == R.id.ac_pcode_tv) {
            FileUtil.saveImageToGallery(this, bitmap);
            showToast("保存相册成功");
        }
    }
}
